<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <span></span>
    <script>

        (function () {
            var span = document.querySelector("span")
            setInterval(function () {
                var time = new Date()
                nian = time.getFullYear()
                yue = time.getMonth() + 1
                day = time.getDate()
                h = time.getHours()
                m = time.getMinutes()
                s = time.getSeconds()
                span.innerHTML = "今天是：" + nian + "年" + yue + "月" + day + "日&nbsp;&nbsp;" + h + "时" + m + "分" + s + "秒"
            }, 1000)
        }())
    </script>
</body>

</html>